<?php

add_action( 'init', 'register_my_menu' );

function register_my_menu() {
	register_nav_menu( 'primary', __( 'Primary Menu' ) );
        register_nav_menu( 'footer', __( 'Footer Menu' ) );
}

add_action('admin_print_scripts', 'admin_scripts');

function admin_scripts() {
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-core');
    wp_enqueue_script('jquery-ui-sortable');
    wp_enqueue_script('media-upload');
    wp_enqueue_script('thickbox');
    wp_register_script('mytheme_upload', get_bloginfo('template_url') . '/js/script.js', array());
    wp_enqueue_script('mytheme_upload');
}


/* Breadcrumb */
function breadcrumb($gecerli_sayfa){
	if ( is_page() ){
				$ust_id=$gecerli_sayfa->post_parent;
				$yeni_sorgu = get_post($ust_id);			 
			   if($yeni_sorgu->post_parent) {
				 breadcrumb($yeni_sorgu);
				 echo " > ";
				}
				echo  "<a href=\"".get_permalink($yeni_sorgu->ID)."\" title=\"\" >". get_the_title($yeni_sorgu->ID) ."</a>";
	}
	elseif ( is_single() || is_category() && !is_archive()){
				$ust_id=$gecerli_sayfa->post_parent;
				$yeni_sorgu = get_post($ust_id);			 	
				$kategori= get_the_category($yeni_sorgu->ID);
				$ID = $kategori[0]->cat_ID;
				
				$ayrac=" &#92; ";

				echo get_category_parents($ID, TRUE, $ayrac , FALSE );

				   if($yeni_sorgu->post_parent) {
					 breadcrumb($yeni_sorgu);
						if (! is_category() )  echo " > ";
					}
				
				if ( is_single() ){
					echo  "<a href=\"".get_permalink($yeni_sorgu->ID)."\" title=\"\" >". get_the_title($yeni_sorgu->ID) ."</a>";
				}
	}else{
			 echo  wp_title('');
	}
}

/*if (function_exists('register_sidebar'))
    register_sidebar();*/
    
if ( function_exists('register_sidebar') ){
    register_sidebar(array(
        'name' => 'my_mega_menu',
        'before_widget' => '<div id="my-mega-menu-widget">',
        'after_widget' => '</div>',
        'before_title' => '',
        'after_title' => '',
));
}    
?>
